package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "Delivery_plan", schema = "CRM", catalog = "")
public class DeliveryPlan {
    private long planId;
    private Long recordMoney;
    private Integer rNumber;
    private Timestamp pTime;
    private Integer pCharge;
    private String requirements;
    private String recordDesc;
    private String pBianhao;
    private Customer customerByCustomerId;
    private Order orderByOrderId;
    private Employee employee;
    private String pState;
    private String pFhfou;

    private List<DeliveryScheduleDetails> deliveryScheduleDetails;
    @OneToMany(mappedBy = "deliveryPlanByPlanId")
    public List<DeliveryScheduleDetails> getDeliveryScheduleDetails() {
        return deliveryScheduleDetails;
    }

    public void setDeliveryScheduleDetails(List<DeliveryScheduleDetails> deliveryScheduleDetails) {
        this.deliveryScheduleDetails = deliveryScheduleDetails;
    }

    @Column(name = "P_STATE")
    public String getpState() {
        return pState;
    }

    public void setpState(String pState) {
        this.pState = pState;
    }

    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "p_charge",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
    @Column(name = "p_bianhao")
    public String getpBianhao() {
        return pBianhao;
    }

    public void setpBianhao(String pBianhao) {
        this.pBianhao = pBianhao;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }
    @ManyToOne
    @JoinColumn(name = "order_id", referencedColumnName = "order_id")
    public Order getOrderByOrderId() {
        return orderByOrderId;
    }

    public void setOrderByOrderId(Order orderByOrderId) {
        this.orderByOrderId = orderByOrderId;
    }

    @Id
    @Column(name = "plan_id")
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public long getPlanId() {
        return planId;
    }

    public void setPlanId(long planId) {
        this.planId = planId;
    }

    @Basic
    @Column(name = "record_money")
    public Long getRecordMoney() {
        return recordMoney;
    }

    public void setRecordMoney(Long recordMoney) {
        this.recordMoney = recordMoney;
    }

    @Basic
    @Column(name = "r_number")
    public Integer getrNumber() {
        return rNumber;
    }

    public void setrNumber(Integer rNumber) {
        this.rNumber = rNumber;
    }
    @Basic
    @Column(name = "P_FHFOU")
    public String getpFhfou() {
        return pFhfou;
    }

    public void setpFhfou(String pFhfou) {
        this.pFhfou = pFhfou;
    }

    @Basic
    @Column(name = "p_time")
    public Timestamp getpTime() {
        return pTime;
    }

    public void setpTime(Timestamp pTime) {
        this.pTime = pTime;
    }

    @Basic
    @Column(name = "p_charge")
    public Integer getpCharge() {
        return pCharge;
    }

    public void setpCharge(Integer pCharge) {
        this.pCharge = pCharge;
    }

    @Basic
    @Column(name = "requirements")
    public String getRequirements() {
        return requirements;
    }

    public void setRequirements(String requirements) {
        this.requirements = requirements;
    }

    @Basic
    @Column(name = "record_desc")
    public String getRecordDesc() {
        return recordDesc;
    }

    public void setRecordDesc(String recordDesc) {
        this.recordDesc = recordDesc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DeliveryPlan that = (DeliveryPlan) o;
        return planId == that.planId &&
                Objects.equals(recordMoney, that.recordMoney) &&
                Objects.equals(rNumber, that.rNumber) &&
                Objects.equals(pTime, that.pTime) &&
                Objects.equals(pCharge, that.pCharge) &&
                Objects.equals(requirements, that.requirements) &&
                Objects.equals(recordDesc, that.recordDesc);
    }

    @Override
    public int hashCode() {
        return Objects.hash(planId, recordMoney, rNumber, pTime, pCharge, requirements, recordDesc);
    }
}
